package com.itheima.Demo02;

import java.io.FileReader;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Properties;

public class Demo {
    public static void main(String[] args) throws Exception {
        Properties p = new Properties();
        p.load(new FileReader("Day21codes\\aaa.txt"));
        //通过键获取值
        String cn = p.getProperty("classname");
        String mn = p.getProperty("methodname");
        //创建对象
        //1.获取字节码对象
        Class c = Class.forName(cn);
        //2.获取构造方法
        Constructor con = c.getConstructor();
        //执行构造方法;
        Animal a = (Animal) con.newInstance();
        //调用方法
        //1.获取方法
        Method method = c.getMethod(mn);
        method.invoke(a);

    }
}
